package com.android.cargoapp.cargoapp_gui_prototype;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

import com.slidingmenu.lib.app.SlidingActivity;

public class MeinOpel extends SlidingActivity{
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.mein_opel);
		
		setBehindContentView(R.layout.activity_menu);
		getSlidingMenu().setBehindWidth(300);
		
		String[] menu_items_array = getResources().getStringArray(R.array.menu_entries);
		ArrayAdapter<String> menu_list_adapter = new ArrayAdapter<String>(this, R.layout.menu_item,menu_items_array);
		
		ListView menu = (ListView) findViewById(R.id.menu_lv);
		menu.setAdapter(menu_list_adapter);
		
		getSlidingMenu().setFadeDegree(0.35f);
		
		((TextView) findViewById(R.id.textView1)).setText(getIntent().getExtras().getString("name"));
		
		__setMenuOnClickListener(this, menu);
	}
	
	private void __setMenuOnClickListener(final Context c, ListView menu){

		menu.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View item, int position,
					long id) {
				Intent i = new Intent();
				i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				switch (position) {
				case 0:
					i.putExtra("name", "Mein Opel");
					i.setClassName("com.android.cargoapp.cargoapp_gui_prototype", MeinOpel.class.getName());
					startActivity(i);
					break;
					
				case 1:
					i.putExtra("name", "Einstellungen");
					i.setClassName("com.android.cargoapp.cargoapp_gui_prototype", MeinOpel.class.getName());
					startActivity(i);
					break;
				
				case 2:
					i.putExtra("name", "Hilfe");
					i.setClassName("com.android.cargoapp.cargoapp_gui_prototype", MeinOpel.class.getName());
					startActivity(i);
					break;
					
				default:
					Toast.makeText(c, "Nanananana :P", Toast.LENGTH_LONG).show();
					break;
				}
				
			}
		});
	}

}